/**
* Created by wust on 2020-05-01 20:32:48.
*/
<template>
  <el-form ref="formModel" :model="formModel" :rules="rules" label-width="120px" style="width:70%;" @submit.native.prevent>
      <el-form-item label="data_source_id" prop="dataSourceId">
<el-input v-model="formModel.dataSourceId"></el-input>
</el-form-item>
<el-form-item label="actual_table" prop="actualTable">
<el-input v-model="formModel.actualTable"></el-input>
</el-form-item>
<el-form-item label="logical_table" prop="logicalTable">
<el-input v-model="formModel.logicalTable"></el-input>
</el-form-item>
<el-form-item label="sharding_column" prop="shardingColumn">
<el-input v-model="formModel.shardingColumn"></el-input>
</el-form-item>

      <el-form-item style="text-align: left;">
        <el-button type="primary" @click="onSubmit('formModel')" :loading="submitting">提交</el-button>
      </el-form-item>
  </el-form>
</template>
<script>
import Vue from 'vue'

export default {
  name: 'data-source-detail-update',
  props: ['selectedModel'],
  data () {
    return {
      submitting: false,
      formModel: {
        id: null,
dataSourceId: null,
actualTable: null,
logicalTable: null,
shardingColumn: null,

      },
      rules: {
      }
    }
  },
  created: function () {
    this.formModel = this.selectedModel
  },
  methods: {
    onSubmit: function (formData) {
      this.$refs[formData].validate((valid) => {
        if (!valid) {
        } else {
          Vue.$ajax({
            method: 'put',
            url: Vue.$adminServerURL + '/web/v1/DataSourceDetailController',
            data: this.formModel
          }).then(res => {
            if (res.data.flag !== 'SUCCESS') {
              if (!Vue.$isNullOrIsBlankOrIsUndefined(res.data.message)) {
                this.$message({
                  message: res.data.message,
                  type: 'warning'
                })
              }
            } else {
              this.$message({
                message: res.data.message,
                type: 'success'
              })
            }
          })
        }
      })
    }
  }
}
</script>
